<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Home extends Base_Controller {

    public function index() {
        $query = $this->db->select('*')->limit(9)->get('qbjh_software');
        $softwarelist = $query->result_array();
        $query = $this->db->select('*')->where("tid=1")->order_by('createtime DESC')->limit(6)->get('qbjh_article');
        $articlelist = $query->result_array();
        $this->data['softwarelist'] = $softwarelist;
        $this->data['articlelist'] = $articlelist;
        $this->load->view('public/head', $this->data);
        $this->load->view('pages/index');
        $this->load->view('public/foot');
    }

    public function getPlancode() {
        $redata = $this->httpcode;
        $tid = $this->input->get('tid');
        $where = [
            'tid' => $tid,
            'is_expired' => 0
        ];
        $limit = $this->getLimit($tid);
        $planer = $this->getPlaner($tid);
        $query = $this->db->select('*')->where($where)->order_by('planer_tid ASC')->limit($limit)->get('qbjh_plancode');
        $db_plancode = $query->result_array();
        if ($db_plancode) {
            foreach ($db_plancode as $k => $v) {
                $v['planer_name'] = $planer[$k];
                $plancode[$k] = $v;
            }
        }
        $redata['plancode'] = $plancode;
        echo json_encode($redata);
    }
    

}
